﻿using System;
using System.Data;
using System.Collections.Generic;
using LTP.Common;
using TuKu.Model;
namespace TuKu.BLL
{
    /// <summary>
    /// 业务逻辑类urlsubtable 的摘要说明。
    /// </summary>
    public class urlsubtable
    {
        private readonly TuKu.DAL.urlsubtable dal = new TuKu.DAL.urlsubtable();
        public urlsubtable()
        { }
        #region  成员方法
        public bool Exist(string url)
        {
            return dal.Exist(url);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(TuKu.Model.urlsubtable model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TuKu.Model.urlsubtable model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int id)
        {

            dal.Delete(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TuKu.Model.urlsubtable GetModel(int id)
        {

            return dal.GetModel(id);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<TuKu.Model.urlsubtable> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<TuKu.Model.urlsubtable> modelList = new List<TuKu.Model.urlsubtable>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                TuKu.Model.urlsubtable model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TuKu.Model.urlsubtable();
                    if (ds.Tables[0].Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[n]["id"].ToString());
                    }
                    model.url = ds.Tables[0].Rows[n]["url"].ToString();
                    model.title = ds.Tables[0].Rows[n]["title"].ToString();
                    if (ds.Tables[0].Rows[n]["currentpage"].ToString() != "")
                    {
                        model.currentpage = int.Parse(ds.Tables[0].Rows[n]["currentpage"].ToString());
                    }
                    model.picPage = ds.Tables[0].Rows[n]["picPage"].ToString();
                    if (ds.Tables[0].Rows[n]["categoryid"].ToString() != "")
                    {
                        model.categoryid = int.Parse(ds.Tables[0].Rows[n]["categoryid"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["addtime"].ToString() != "")
                    {
                        model.addtime = DateTime.Parse(ds.Tables[0].Rows[n]["addtime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法

        public void UpdateUrl(int id, string picPage)
        {
            dal.UpdateUrl(id, picPage);
        }
    }
}

